﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using HNCDataSetTableAdapters;

public partial class Admin_Home_About : System.Web.UI.Page
{
    ProductsTableAdapter pro = new ProductsTableAdapter();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            loadAbout(2);
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        int i = pro.UpdateProductByCateID(null, txtTitle.Text, txtTitle.Text, txtDescription.Text, txtDescription.Text, txtContent.Value, txtContent.Value, null, null, null, null, null, 2, DateTime.Now, DateTime.Now, "hnc", false, false, false, null, null, null, null, 1, true, false);
        if (i>0)
        {
            lblMsg.Text = "Cập nhật thành công !";
            loadAbout(2);
        }
        else
        {
            lblMsg.Text = "Cập nhật thất bại !";
        }
    }

    public void loadAbout(int cateid)
    {
        DataTable dt = pro.GetProductByCateID(cateid);
        txtTitle.Text = dt.Rows[0]["Title"].ToString();
        txtDescription.Text = dt.Rows[0]["Description"].ToString(); 
        txtContent.Value = dt.Rows[0]["Content"].ToString(); 
    }
    
}